package com.cn.xiaonuo.modular.controller.app;



import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cn.xiaonuo.core.pojo.response.ResponseData;
import com.cn.xiaonuo.modular.model.app.UserFocus;
import com.cn.xiaonuo.modular.model.app.UserInfo;
import com.cn.xiaonuo.modular.service.app.UserFocusService;


@Controller
@RequestMapping("/userFocus")
public class UserFocusController {
	@Autowired
    private UserFocusService userFoucsService;
	
	//查询关注列表
	  @ResponseBody
	    @PostMapping("/queryUserFocus")
	    public ResponseData queryUserFocus(UserFocus userFocus) {
	    	List<UserInfo> list=userFoucsService.queryList(userFocus);
	    	ResponseData r=new ResponseData();
	    	r.setData(list);
	    	r.setSuccess(true);
	        return r;
	     
	    }
	  //添加关注或取关
	  @ResponseBody
	    @PostMapping("/insertOrDeleteUserFocus")
	    public ResponseData insertOrDeleteUserFocus(UserFocus userFocus) {
		  if(null!=userFocus) {
			  if(null!=userFocus.getFlag() && !"".equals(userFocus.getFlag())) {
				  if(userFocus.getFlag().equals("1")) {
					  userFoucsService.insertUserFocus(userFocus);
				  }else {
					  userFoucsService.deleteUserFocus(userFocus); 
				  }
			  }
		  }
		
		  return ResponseData.success();
	     
	    }
	  
}
